package com.example.neo4j.controller;

import com.example.neo4j.service.GraphService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api")
public class GraphController {

    @Autowired
    private GraphService graphService;

    /**
     * Get graph 查询
     *
     * @return
     */
    @GetMapping("/graph")
    public Map<String, Object> getGraph() {
        return graphService.getGraph();
    }

    /**
     * 获取到所有的labels（标签）
     */
    @GetMapping("/labels")
    public Map<String, Object> getLabels() {
        return graphService.getLabels();
    }

    /**
     * 根据标签label获取对应的数据
     */
    @GetMapping("/dataByLabel")
    public Map<String, Object> getDataByLabel(@RequestParam(value = "label", required = false) String label) {
        return graphService.getDataByLabel(label);
    }
}
